<?php 
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.tooltip');

$listOrder	= @$this->lists['order'];
$listDirn	= @$this->lists['order_Dir'];
?>
<table class="adminlist table">
	<thead>
		<tr>
		 	<th width="20">
				<?php echo JHtml::_('grid.checkall'); ?>
			</th>
			<th nowrap="nowrap">
		 		<?php echo JHTML::_('grid.sort',  'Date', 'r.exchange_date', $listDirn, $listOrder ); ?>
		 	</th>		
		 	<th nowrap="nowrap" width="5%">  
		 		<?php echo JHTML::_('grid.sort',  'Member Id', 'p.member_id', $listDirn, $listOrder ); ?>
		 	</th>		
		 	<th nowrap="nowrap" width="20%"> 
		 		<?php echo JHTML::_('grid.sort',  'Name', 'p.f_name', $listDirn, $listOrder ); ?>
		 	</th>
		 	<th nowrap="nowrap" width="10%">  
		 		<?php echo JHTML::_('grid.sort',  'Phone', 'p.phone', $listDirn, $listOrder ); ?>
		 	</th>
		 	<th nowrap="nowrap" width="5%">  
		 		<?php echo 'Code' ; ?>
		 	</th>		
		 	<th nowrap="nowrap" width="10%">  
		 		<?php echo JHTML::_('grid.sort',  'Gift Name', 'pro.name', $listDirn, $listOrder ); ?>
		 	</th>			
		 	<th nowrap="nowrap" width="3%">  
		 		<?php echo 'Quantity' ; ?>
		 	</th>	
		 	<th nowrap="nowrap" width="10%"> 
		 		<?php echo JHTML::_('grid.sort',  'Points Used ', 'r.point', $listDirn, $listOrder ); ?>
		 	</th>	
		 	<th nowrap="nowrap" width="10%">  
		 		<?php echo JHTML::_('grid.sort',  'Cash Used', 'r.cash', $listDirn, $listOrder ); ?>
		 	</th>
		 	<th nowrap="nowrap" width="10%">  
		 		<?php echo 'Current Points' ; ?>
		 	</th>	
		 	<th nowrap="nowrap" width="25%">  
		 		<?php echo JHTML::_('grid.sort',  'Outlet', 'p.pick_up_at', $listDirn, $listOrder ); ?>
		 	</th>
		 	<th nowrap="nowrap" width="10%">  
		 		<?php echo JHTML::_('grid.sort',  'Delivery To Outlet', 'r.status_of_redemption_date', $listDirn, $listOrder ); ?>
		 	</th>
		 	<th nowrap="nowrap" width="10%">  
		 		<?php echo JHTML::_('grid.sort',  'Pick Up Date', 'r.pick_up_date', $listDirn, $listOrder ); ?>
		 	</th>
		 	<th nowrap="nowrap" width="10%">  
		 		<?php echo JHTML::_('grid.sort',  'Status', 'r.status_of_redemption', $listDirn, $listOrder ); ?>
		 	</th>
		</tr>
	</thead>
	<tbody>
		 <?php
           	$k = 0;
           	if(count($this->items) > 0):
				for ($i=0, $n= count( $this->items ); $i < $n; $i++):
					$row = &$this->items[$i];
					$checked 	= JHTML::_('grid.checkedout',   $row, $i);
		            $canChange	= $user->authorise('core.edit.state', 'com_wrd.reports.'.$row->id);
					$published 	= JHTML::_('jgrid.published', $row->published, $i,'reports.', $canChange,'cb');
			?>	
			 	<tr class="<?php echo "row$k"; ?>" >
			 		<td>
						<?php echo $checked; ?>
					</td>
					<td><?php echo $row->exchange_date ; ?></td>				
				 	<td><?php echo $this->user_info[$row->user_id]->member_id ; ?></td>
				 	<td>
				 		<a href='index.php?option=com_wrd&controller=profile&id=<?php echo $this->user_info[$row->user_id]->id ; ?>&layout=form'>
							<img src="<?php echo JURI::base().'components/com_wrd/assets/images/details.png' ?>" alt='Profile of <?php echo $this->user_info[$row->user_id]->f_name.' '.$this->user_info[$row->user_id]->l_name ; ?>' title='Profile of <?php echo $this->user_info[$row->user_id]->f_name.' '.$this->user_info[$row->user_id]->l_name ; ?>' />
						</a>
				 		<a href="index.php?option=com_wrd&controller=profile&layout=rdetails&id=<?php echo $row->id; ?>">
				 			<?php echo $this->user_info[$row->user_id]->f_name.' '.$this->user_info[$row->user_id]->l_name ; ?>
				 		</a>
				 	</td>
				 	<td><?php echo $this->user_info[$row->user_id]->phone ; ?></td>	
				 	<td><?php echo $this->redemption[$row->id]->code ; ?></td>
				 	<td><?php echo $this->p_details[$row->product_id]->name ; ?></td>
				 	<td><?php echo '1' ; ?></td>
				 	<td><?php echo $row->point ; ?></td>
				 	<td><?php if(!empty($row->cash)){ echo $row->cash ; } ; ?>&nbsp;</td>
				 	<td><?php echo $this->p_o_u[$row->user_id] ; ?></td>
				 	<td><?php echo $this->outlet_info[$row->id]->name ; ?></td>
				 	<td>
					 	<?php
						 	if($row->status_of_redemption_date != '0000-00-00 00:00:00' && !empty($row->status_of_redemption_date) && $row->status_of_redemption == 3) {
						 		echo $row->status_of_redemption_date ;
						 	}	
					 	?>&nbsp;
				 	</td>			
				 	<td>
					 	<?php 
						 	if($row->pick_up_date != '0000-00-00' && !empty($row->pick_up_date)) {
						 		echo $row->pick_up_date ;
						 	}	
					 	?>&nbsp;
				 	</td>
				 	<td>
				 		<?php 
					 		switch ($row->status_of_redemption){
					 			case '1':
				 					echo 'Unverify' ;
					 				break ;
				 				case '2':
				 					echo 'Waiting for approval' ;
					 				break ;
				 				case '3':
				 					echo 'Deliver to outlet' ;
					 				break ;
				 				case '4':
				 					echo 'Picked up' ;
					 				break ;
					 		}
				 		?>
				 	</td>
			 	</tr>
			 <?php 
				 $k = 1 - $k ;	 
				 endfor; 
				 endif; 
			 ?>
		 </tbody>
		 <tfoot>
			<tr>
				<td colspan="16">
                    <?php
                         echo $this->pagination->getListFooter();
                    ?>
                </td>
			</tr>
		</tfoot>
	</table>